﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.DOM.HTML
{
    #region Using Statements

    using System;

    #endregion

    /// <summary>
    /// Preformatted text. See the PRE element definition in HTML 4.01.
    /// </summary>
    public class HTMLBRElement : HTMLElement
    {
        public const string ATTR_CLEAR_NONE = "none";
        public const string ATTR_CLEAR_LEFT = "left";
        public const string ATTR_CLEAR_RIGHT = "right";
        public const string ATTR_CLEAR_ALL = "all";

        #region Constructors

        internal HTMLBRElement(Document owner)
            : base(owner, HTMLConstants.HTML_TAG_BR)
        {
        }

        #endregion

        #region DOM Level 2 HTML Compliance

        /// <summary>
        /// Force a line break. See the BR element definition in HTML 4.01.
        /// </summary>
        [Obsolete]
        public string clear
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_CLEAR);
            }
            set
            {
                if (String.IsNullOrEmpty(value))
                    removeAttribute(HTMLConstants.HTML_ATT_CLEAR);
                else
                {
                    switch (value.ToLowerInvariant())
                    {
                        case ATTR_CLEAR_ALL:
                        case ATTR_CLEAR_LEFT:
                        case ATTR_CLEAR_NONE:
                        case ATTR_CLEAR_RIGHT:
                            setAttribute(HTMLConstants.HTML_ATT_CLEAR, value.ToLowerInvariant());
                            break;
                        default:
                            break;
                    }
                }
            }
        }

        #endregion
    }
}
